#include <iostream>
using std::cout;
using std::endl;

//省略号写在左边，意味着打包
template <class ...Args>  
void display(Args ...args){
    cout << "sizeof...(Args):" << sizeof...(Args) << endl;
    cout << "sizeof...(args):" << sizeof...(args) << endl;
}

void test0(){
    display();
    display(1,2,3,4.5);
    display(1.2,"hello",4,true);
    display(1.2,"hello",4,true,88,66,'a');
}

//对参数包进行解包
//需要一个递归的出口
void print(){
    cout << endl;
}

void print(bool x){
    cout << x << endl;
}

template <class T, class ...Args>
void print(T x, Args ...args){
    cout << x << " ";
    //省略号写在右边意味着解包
    //递归调用print
    print(args...);
}

void test1(){
    /* print(); */
    print(2.5);

    //cout << 1.2 << " ";
    //print("hello",4,true);
    //  cout << "hello" << " ";
    //  print(4,true);
    //      cout << 4 << " ";
    //      print(true);
    //          cout << true << " ";
    //          print();//调用普通函数
    print(1.2,"hello",4,true);
}

//准备好递归的出口
/* int sum(int x){ */
/*     return x; */
/* } */

int sum(){
    return 0;
}

template <class T, class ...Args>
double sum(T x, Args ...args){
    return x + sum(args...);
}

void test2(){
    //2.4 + sum(...)
    //2.4 + (2 + sum(...))
    cout << sum(2.4,2,3.4,6,7.8,90) << endl;
}

int main(void){
    test2();
    return 0;
}
